<template>
    <div>
        <input type="text" ref="getChild" @keyup="changeVal($event)">
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
const getChild = ref<HTMLInputElement | null>(null)

const changeVal = (e: Event) => {
    // console.log((getChild.value as HTMLInputElement).value)  //通过ref获取input中的value
    // console.log((e.target as HTMLInputElement).value)        //通过event获取input数据
    console.log(getChild.value?.value)
    // console.log(getChild.value && getChild.value.value)

}
</script>

<style scoped></style>